package com.hzdl.car.mapper;

import com.hzdl.car.bean.BaseStat;
import com.hzdl.car.bean.Customer;
import com.hzdl.car.sqlprovider.CustomerSqlProvider;
import com.hzdl.car.vo.CustomerVo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CustomerMapper {
    @SelectProvider(type = CustomerSqlProvider.class,method = "findCustomer")
    List<Customer> findCustomer(CustomerVo customerVo);
    @Delete("delete from bus_customer where identity=#{identity}")
    int delCustomer(CustomerVo customerVo);
    @Insert("insert into bus_customer (identity,custName,sex,address,phone,career,createTime) " +
            "values (#{identity},#{custName},#{sex},#{address},#{phone},#{career},now())")
    int addCustomer(CustomerVo customerVo);
    @Update("update bus_customer set custName=#{custName},sex=#{sex},address=#{address}," +
            "phone=#{phone},career=#{career} where identity=#{identity}")
    int updateCustomer(CustomerVo customerVo);
    @Select("select * from bus_customer where identity=#{id}")
    List<Customer> findCustomerById(String id);
    //显示客户地区数据
    @Select("select address name,count(0) value from bus_customer group by address")
    List<BaseStat> findCustomerAddress();

}
